{{!-- const object = {{{json object}}}; --}}
import { h,reactive } from 'vue';
import { ElButton,ElLink,ElTag } from 'element-plus'
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
const editRow=(row)=>{
  const id =row.id
}
const deleteRow=(row)=>{
  const id =row.id
}
const infoRow=(row)=>{
  const id =row.id
}
const crudSchemas = reactive<CrudSchema[]>([

  {{#if mixDataStructure}}
    {{#if showSelection}}
      { field: 'selection',type: 'selection',form:{hidden:true},table:{hidden:false},search:{hidden:true},detail:{hidden:true} },
    {{/if}}

    {{#if showIndex}}
      { field: 'index',label:'序号',type:'index',form:{hidden:true},table:{hidden:false},search:{hidden:true},detail:{hidden:true} },
    {{/if}}

    {{#each object}}
      { field: '{{@key}}', label: '字段名{{@index}}',form:{hidden:false},table:{hidden:false},search:{hidden:true},detail:{hidden:false} },
    {{/each}}

    {{#if showActionColumn}}
      { field: 'action',label:'操作',table:{ slots:{ default:(data:any) => {return [h(ElButton, {onClick:()=>editRow(data.row)}, '编辑'),h(ElButton, {onClick:()=>infoRow(data.row)}, '详情'),h(ElButton, {onClick:()=>deleteRow(data.row)}, '删除')] } } },form:{hidden:true},search:{hidden:true},detail:{hidden:true} }
    {{/if}}

  {{else}}
      {{#each object}}
      { field: '{{@key}}', label: '字段名{{@index}}'},
      {{/each}}

      {{#if showActionColumn}}
      { field: 'action',label:'操作',slots:{ default:(data:any) => {return [h(ElButton, {onClick:( )=>editRow(data.row)}, '编辑'),h(ElButton, {onClick:()=>infoRow(data.row)}, '详情'),h(ElButton, {onClick:()=>deleteRow(data.row)}, '删除')] } } }
      {{/if}}

  {{/if}}

])

const { allSchemas } = useCrudSchemas(crudSchemas)
export { allSchemas, crudSchemas }
